package com.easygo.controller;

import com.easygo.client.UserServiceClient;
import com.easygo.common.ResultResponse;
import com.easygo.pojo.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class UserController {

    private static final String REST_URL_PREFIX = "http://EASYGO-USER-SERVER";

//    //调用用户服务
//    @Autowired
//    RestTemplate restTemplate;
//
//    @Autowired
//    DiscoveryClient discoveryClient;

    @Resource
    UserServiceClient userServiceClient;

    @ApiOperation(value = "获取所有用户基本信息列表", notes = "详细描述信息SpringCloud基础入门程序，一定搞定！")
    @GetMapping("/users")
    @ResponseBody
    public List<User> getUsers(){
        return userServiceClient.list();
    }

    @ApiOperation(value = "获取所有用户基本信息列表", notes = "详细描述信息SpringCloud基础入门程序，一定搞定！")
    @GetMapping("/user_list")
    @ResponseBody
    public List<User> getAll(){
        return userServiceClient.list();
    }

    @PostMapping("/user_register")
    @ResponseBody
    public ResultResponse userRegist(User user){
       return userServiceClient.userRegist(user);
    }

}
